﻿using System;
using System.Diagnostics;
using TI_BLE_HCI_ClientLib.HCIBaseEntities;
using TI_BLE_HCI_ClientLib.HCIEvents;
using Utilities;

namespace TI_BLE_HCI_ClientLib.HCIParsers
{
    public static partial class HCIEventParser
    {
        private static void parseHCI_LE_ExtEvent_GATT_Base_Event(byte parsLen, byte[] buffer,
            out HCIVendorSpecificEventHostErrorCode status,
            out ushort connHandle,
            out byte pduLen,
            out byte[] pdu)
        {
            if (parsLen < 5) throw new ArgumentException("parseHCI_LE_ExtEvent_GATT_BaseEvent Parameters Length < 5");
            byte bufIdx = 4;

            status = (HCIVendorSpecificEventHostErrorCode)parseByteParameter(buffer, ref bufIdx);
            connHandle = parseWordParameter(buffer, ref bufIdx);
            pduLen = parseByteParameter(buffer, ref bufIdx);
            pdu = parseBufferParameter((byte)(parsLen - 6), buffer, ref bufIdx);
        }
    }
}
